/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo.DAL;

/**
 *
 * @author Juan Reyes
 */
import java.util.Map;
import java.util.HashMap;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.JasperRunManager;

public class InformeRiesgos_DAO {

    public InformeRiesgos_DAO() {
    }

    public byte[] generarInforme(Map parametros) {
        ConexionBD conexion = new ConexionBD();
        byte[] pdf = null;
        String filename = "/Modulo3/informeRiesgos.jasper";
        JasperReport masterReport = null;

        try {
            masterReport = (JasperReport) JRLoader.loadObject(getClass().getResource(filename));
            pdf = JasperRunManager.runReportToPdf(masterReport, parametros, conexion.session);
        } catch (JRException e) {
            System.out.print("Error Generando informe de riesgos. Problemas de datos");
        }

        if (conexion.session != null) {
            conexion.cerrarConexion();
        }

        return pdf;
    }
}
